﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using SWE2Model;

/// <summary>
/// Summary description for change_password
/// </summary>
public class change_passwordd
{
    public static bool changing_password(string username, string old_password, string new_password)
    {

        using (SWE2Entities db = new SWE2Entities())
        {
            UserInfo_Table st = new UserInfo_Table();
            st = (from mt in db.UserInfo_Table where mt.Username == username select mt).FirstOrDefault();
            try
            {
                if (st.Password != old_password)
                {
                    return false;
                }

                else
                    if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(old_password))
                    {
                        return false;
                    }
                    else

                        st.Password = new_password;
                db.SaveChanges();
                return true;

            }
            catch
            {
                return false;
            }

        }


    }





}